package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class NewForDemo {
    public static void main(String[] args) {
        //新循环---->增强for循环
        String[] arr={"one","two","three","four","five"};
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        System.out.println("------------------------");
        System.out.println(Arrays.toString(arr));
        System.out.println("------------------------");
        for (String str: arr){
            System.out.println(str);
        }
        System.out.println("--------------------------");

        Collection<String> c=new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator it=c.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
        System.out.println("--------------------------");
        for (Object str: c){//String
            System.out.println(str);
        }
        System.out.println("--------------------------");

    }
}
